package com.uit.se6.mydiary;


import com.uit.se6.mydiary.note.NoteFactory;
import com.uit.se6.mydiary.note.NotesDbAdapter;

import android.content.Intent;
import android.os.Bundle;
import android.text.format.Time;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class DiaryMenu extends BaseActivity {
	private Button mbtnNew;
	private NotesDbAdapter notesDbAdapter;
	private int mYear;
	private int mMonth;
	private int mDay;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.diary_menu);
		notesDbAdapter = new NotesDbAdapter(this);
		notesDbAdapter.open();
		
		final Time today = new Time(Time.getCurrentTimezone());
		today.setToNow();
		mYear = today.year;
        mMonth=today.month;
        mDay=today.monthDay;		
		mbtnNew = (Button) findViewById(R.id.btn_new);
		mbtnNew.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				
				Intent intent = new Intent(DiaryMenu.this, DiaryEdit.class);
				Toast.makeText(getApplicationContext(), mDay+"/"+mMonth+"/"+mYear+"/", Toast.LENGTH_LONG).show();
				NoteFactory.createNote(DiaryMenu.this, notesDbAdapter, String.valueOf(mYear),String.valueOf(mMonth) , String.valueOf(mDay));
				
				startActivity(intent);
				
				
			}
		});
	}
}
